package com.benyanyi.okhttp.type;

import android.content.Context;

import androidx.annotation.NonNull;

import com.benyanyi.okhttp.util.OkHttpLog;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

import okhttp3.logging.HttpLoggingInterceptor;

/**
 * @author YanYi
 * @date 2019-08-12 16:50
 * @email ben@yanyi.red
 * @overview
 */
class HttpConfig {

    static HttpLoggingInterceptor HTTP_LOGGING_INTERCEPTOR =
            new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
                @Override
                public void log(@NonNull String message) {
                    OkHttpLog.d(message);
                }
            }).setLevel(HttpLoggingInterceptor.Level.BODY);

    static HttpLoggingInterceptor HTTP_LOGGING_INTERCEPTOR_FILE =
            new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
                @Override
                public void log(@NonNull String message) {
                    OkHttpLog.d(message);
                }
            }).setLevel(HttpLoggingInterceptor.Level.HEADERS);

    /**
     * 设置缓存路径，以及缓存文件大小
     */
    static okhttp3.Cache privateCache(Context mContext) {
        return new okhttp3.Cache(mContext.getCacheDir(), 10240 * 10240);
    }
//    fun verifier(): HostnameVerifier
//
//    {
//        return HostnameVerifier { _, _ -> true }
//
//    }

    static HostnameVerifier verifier() {
        return new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        };
    }

}
